package com.lishu.carsafe.activity;

import android.os.Bundle;
import android.os.Environment;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.MediaController;
import android.widget.VideoView;

import com.lishu.carsafe.R;
import com.lishu.carsafe.utils.ToastUtil;

public class PlayVideoActivity extends BaseActivity{
    private String path;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_play_video);

        path = getIntent().getExtras().getString("videoPath");
        //ToastUtil.showShort(path);
        //path = "http://vfx.mtime.cn/Video/2019/03/19/mp4/190319212559089721.mp4";

        initView();
    }

    private void initView() {
        setTopTitle("视频播放");

        VideoView videoView = (VideoView)findViewById(R.id.videoView);

        //加载指定的视频文件
        videoView.setVideoPath(path);

        //创建MediaController对象
        MediaController mediaController = new MediaController(this);
        mediaController.setVisibility(View.VISIBLE);

        //VideoView与MediaController建立关联
        videoView.setMediaController(mediaController);

        //让VideoView获取焦点
        videoView.requestFocus();


        videoView.start();
    }



}
